package com.ebelter.btcomlib.models.bluetooth.products.temperature2;

import android.nfc.Tag;

import com.ebelter.btcomlib.models.bluetooth.bean.SendMessage;
import com.ebelter.btcomlib.utils.BytesUtils;
import com.ebelter.btcomlib.utils.log.LogUtils;

/**
 * Created by pan on 2018/7/24
 */

public class Temperature2BytesMake {



    private static final String desc1="停止发送当前测试结果";
    public static final byte[] ReceiveSuccessAck=new byte[]{(byte) 0x02,0x20, (byte) 0xdd,0x02, (byte) 0xfd,0x29,43};
    public SendMessage getReceiveSuccessAck(){
        SendMessage sendMessage = new SendMessage();
        sendMessage.datas=ReceiveSuccessAck;
        sendMessage.desc=desc1;
        return sendMessage;
    }

    public static int getBytesXor(byte[] bytes){
        int checkData = 0;
        for (int i = 1; i < bytes.length-1; i++) {
            checkData = bytes[i] ^ checkData;
            LogUtils.i("Temperature2BytesMake","checkData="+checkData+"---bytes["+i+"]="+ BytesUtils.bytes2HexStr2(new byte[]{bytes[i]}));
        }
        return checkData;

    }


    private static final String desc2="关机";
    public static final byte[] OffDevice=new byte[]{(byte) 0x02,0x20, (byte) 0xdd,0x02, (byte) 0xfd,0x30,50};
    public SendMessage getOffDevice(){
        SendMessage sendMessage=new SendMessage();
        sendMessage.desc=desc2;
        sendMessage.datas=OffDevice;
        return sendMessage;
    }

    private static final String desc3="设置单位为°C";
    public static final byte[] setUnitC=new byte[]{(byte) 0x02,0x20, (byte) 0xdd,0x02, (byte) 0xfd,0x31,51};
    public SendMessage setUnitC(){
        SendMessage sendMessage=new SendMessage();
        sendMessage.desc=desc3;
        sendMessage.datas=setUnitC;
        return sendMessage;
    }

    private static final String desc4="设置单位为°F";
    public static final byte[] setUnitF=new byte[]{(byte) 0x02,0x20, (byte) 0xdd,0x02, (byte) 0xfd,0x32,48};
    public SendMessage setUnitF(){
        SendMessage sendMessage=new SendMessage();
        sendMessage.desc=desc4;
        sendMessage.datas=setUnitF;
        return sendMessage;
    }


    private static final String desc5="请求最新（未上传）历史数据";
    public static final byte[] getNewestHistoryData=new byte[]{(byte) 0x02,0x20, (byte) 0xdd,0x02, (byte) 0xfd,0x33,49};
    public SendMessage getNewestHistoryData(){
        SendMessage sendMessage=new SendMessage();
        sendMessage.desc=desc5;
        sendMessage.datas=getNewestHistoryData;
        return sendMessage;
    }


    private static final String desc6="读取版本号";
    public static final byte[] getVersionInfo=new byte[]{(byte) 0x02,0x20, (byte) 0xdd,0x02, (byte) 0xfd,0x34,54};
    public SendMessage getVersionInfo(){
        SendMessage sendMessage=new SendMessage();
        sendMessage.desc=desc6;
        sendMessage.datas=getVersionInfo;
        return sendMessage;
    }


    private static final String desc7="请求所有历史数据";
    public static final byte[] getAllHistoryData=new byte[]{(byte) 0x02,0x20, (byte) 0xdd,0x02, (byte) 0xfd,0x35,55};
    public SendMessage getAllHistoryData(){
        SendMessage sendMessage=new SendMessage();
        sendMessage.desc=desc7;
        sendMessage.datas=getAllHistoryData;
        return sendMessage;
    }
}
